package cn.lg.soar.system.auth.entity;

import cn.lg.soar.core.annotations.constraints.group.Create;
import cn.lg.soar.core.annotations.constraints.group.Update;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

/**
 * 临时密码
 * @author luguoxiang
 * @date 2021/9/12
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@Getter
@Setter
@TableName("lg_sys_temporary_password")
public class TemporaryPassword {

    @NotNull(message = "id不能为空", groups = Update.class)
    @TableId
    private Long id;

    @ApiModelProperty("绑定用户id")
    private Long userId;

    @NotBlank(message = "密码不能为空", groups = Create.class)
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @ApiModelProperty("临时密码")
    private String password;

    @JsonIgnore
    @ApiModelProperty("密码盐")
    private String salt;

    @ApiModelProperty("有效期，为空表示不限")
    private LocalDateTime expires;

    @ApiModelProperty("最多允许次数，0表示不限")
    private Integer maxCount;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @ApiModelProperty("已使用次数")
    private Integer usageCount;

    @ApiModelProperty("备注")
    private String remark;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @ApiModelProperty("最近一次登录时间")
    private LocalDateTime lastLoginDate;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @ApiModelProperty("更新时间")
    private LocalDateTime updateTime;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @ApiModelProperty("创建时间")
    private LocalDateTime createTime;

}
